package com.yangxc.applet.controller;

import com.yangxc.applet.api.dto.FunctionConfig;
import com.yangxc.applet.api.dto.SlideShow;
import com.yangxc.core.common.api.Result;
import com.yangxc.core.log.annotation.SysLog;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * @author yangxc
 * @version 1.0.0
 * @ClassName IndexController.java
 * @Description TODO
 * @createTime 2022年10月02日 12:30:00
 */
@RestController
@RequestMapping("/index")
public class IndexController {
    
    /**
     * 获取轮播图
     * @return
     */
    @SysLog("轮播")
    @GetMapping("/slideShow")
    public Result slideShow(){
        ArrayList<SlideShow> slideShows = new ArrayList<>();
        slideShows.add(SlideShow.builder().img("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F015baf5968308ca8012193a3b3130f.jpg&refer=http%3A%2F%2Fimg.zcool.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1667277780&t=b4b489a97daa28f593700a9f4ef73a04").redirect("").build());
        slideShows.add(SlideShow.builder().img("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.meituan.net%2Fiphoenix%2Fba42ad456c4d78d4fdd6686268a2f66f3590330.jpg%40750w_340h_80q_1e%7C750_340m&refer=http%3A%2F%2Fimg.meituan.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1667277780&t=805e7cfcd680f71c7805fa7830555815").redirect("").build());
        slideShows.add(SlideShow.builder().img("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F13773798-13d51dfffd152727.jpg&refer=http%3A%2F%2Fupload-images.jianshu.io&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1667277780&t=f89e32b51745fe03104e0c08e196960b").redirect("").build());
        return Result.data(slideShows);
    }
    
    /**
     * 功能配置
     * @return
     */
    @GetMapping("/functionConfig/{type}")
    public Result functionConfig(@PathVariable String type) {
        ArrayList<FunctionConfig> functionConfigs = new ArrayList<>();
        functionConfigs.add(FunctionConfig.builder().type("1").text("历史今天").img("https://cdn.jsdelivr.net/gh/shenyihan/img/applet/index/2048.png").redirect("../../pages/today/today?title=历史上的今天").build());
        functionConfigs.add(FunctionConfig.builder().type("1").text("照片换底").img("https://cdn.jsdelivr.net/gh/shenyihan/img/applet/index/1cun.png").redirect("../../pages/imgChange/imgChange?title=照片换底").build());
        functionConfigs.add(FunctionConfig.builder().type("1").text("去水印").img("https://cdn.jsdelivr.net/gh/shenyihan/img/applet/index/2048.png").redirect("").build());
        
        functionConfigs.add(FunctionConfig.builder().type("2").text("2048").img("https://cdn.jsdelivr.net/gh/shenyihan/img/applet/index/2048.png").redirect("../../pages/2048/2048").build());
        functionConfigs.add(FunctionConfig.builder().type("2").text("去水印").img("https://cdn.jsdelivr.net/gh/shenyihan/img/applet/index/2048.png").redirect("").build());
        functionConfigs.add(FunctionConfig.builder().type("3").text("去水印").img("https://cdn.jsdelivr.net/gh/shenyihan/img/applet/index/2048.png").redirect("").build());
        functionConfigs.add(FunctionConfig.builder().type("2").text("去水印").img("https://cdn.jsdelivr.net/gh/shenyihan/img/applet/index/2048.png").redirect("").build());
        functionConfigs.add(FunctionConfig.builder().type("2").text("去水印").img("https://cdn.jsdelivr.net/gh/shenyihan/img/applet/index/2048.png").redirect("").build());
        return Result.data(functionConfigs);
    }
}
